<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>  
<%@ taglib prefix="ujn" uri="http://ujn.edu.cn/common/"%> 
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() 
	                   + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML> 
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>用户管理</title>
	<!-- 引入css样式文件 -->
	<!-- Bootstrap Core CSS -->
	<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet" />
	<!-- MetisMenu CSS -->
	<link href="<%=basePath%>css/metisMenu.min.css" rel="stylesheet" />
	<!-- DataTables CSS -->
	<link href="<%=basePath%>css/dataTables.bootstrap.css" rel="stylesheet" />
	<!-- Custom CSS -->
	<link href="<%=basePath%>css/sb-admin-2.css" rel="stylesheet" />
	<!-- Custom Fonts -->
	<link href="<%=basePath%>css/font-awesome.min.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath%>css/boot-crm.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
  <!-- 导航栏部分 -->
  <nav class="navbar navbar-default navbar-static-top" role="navigation"
		 style="margin-bottom: 0">
	<div class="navbar-header">
		<a class="navbar-brand" href="<%=basePath%>customer/list.action">客户管理系统</a>
	</div>
	<!-- 导航栏右侧图标部分 -->
	<ul class="nav navbar-top-links navbar-right">
	    <!-- 邮件通知 start -->
		<li class="dropdown">
			<a class="dropdown-toggle" data-toggle="dropdown" href="#"> 邮件通知
			</a>
			<ul class="dropdown-menu dropdown-messages">
				<li>
				    <a href="#">
						<div>
							<strong>张经理</strong> <span class="pull-right text-muted">
								<em>昨天</em>
							</span>
						</div>
						<div>今天晚上开会，讨论一下下个月工作的事...</div>
				    </a>
				</li>
				<li class="divider"></li>
				<li>
				    <a class="text-center" href="#">
				        <strong>查看全部消息</strong>
						
				    </a>
				</li>
			</ul>
		</li>
		<!-- 邮件通知 end -->
		<!-- 任务通知 start -->
		<li class="dropdown">
			<a class="dropdown-toggle" data-toggle="dropdown" href="#"> 任务通知
			</a>
			<ul class="dropdown-menu dropdown-tasks">
				<li>
				    <a href="#">
						<div>
							<p>
								<strong>任务 1</strong> 
								<span class="pull-right text-muted">完成40%</span>
							</p>
							<div class="progress progress-striped active">
								<div class="progress-bar progress-bar-success"
									role="progressbar" aria-valuenow="40" aria-valuemin="0"
									aria-valuemax="100" style="width: 40%">
									<span class="sr-only">完成40%</span>
								</div>
							</div>
						</div>
				    </a>
				</li>
				<li class="divider"></li>
				<li>
				    <a href="#">
						<div>
							<p>
								<strong>任务 2</strong> 
								<span class="pull-right text-muted">完成20%</span>
							</p>
							<div class="progress progress-striped active">
								<div class="progress-bar progress-bar-info" role="progressbar"
									aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"
									style="width: 20%">
									<span class="sr-only">完成20%</span>
								</div>
							</div>
						</div>
				    </a>
				</li>
				<li class="divider"></li>
				<li>
				    <a class="text-center" href="#"> 
				        <strong>查看所有任务</strong>
				    </a>
				</li>
			</ul> 
		</li>
		<!-- 任务通知 end -->
		<!-- 消息通知 start -->
		<li class="dropdown">
			<a class="dropdown-toggle" data-toggle="dropdown" href="#"> 消息通知
			</a>
			<ul class="dropdown-menu dropdown-alerts">
				<li>
				    <a href="#">
						<div>
							 新回复 
							<span class="pull-right text-muted small">4分钟之前</span>
						</div>
				    </a>
				</li>
				<li class="divider"></li>
				<li>
				    <a href="#">
						<div>
							新消息 
							<span class="pull-right text-muted small">4分钟之前</span>
						</div>
				    </a>
				</li>
				<li class="divider"></li>
				<li>
				    <a href="#">
						<div>
							 新任务 
							<span class="pull-right text-muted small">4分钟之前</span>
						</div>
				    </a>
				</li>
				<li class="divider"></li>
				<li>
				    <a href="#">
						<div>
							服务器重启 
							<span class="pull-right text-muted small">4分钟之前</span>
						</div>
				    </a>
				</li>
				<li class="divider"></li>
				<li>
				    <a class="text-center" href="#"> 
				        <strong>查看所有提醒</strong>
				    </a>
				</li>
			</ul> 
		</li>
		<!-- 消息通知 end -->
		<!-- 用户信息和系统设置 start -->
		<li class="dropdown">
			<a class="dropdown-toggle" data-toggle="dropdown" href="#"> 用户信息和系统设置
				
			</a>
			<ul class="dropdown-menu dropdown-user">
				<li><a href="#">
				               用户：${USER_SESSION.user_name}
				    </a>
				</li>
				<li><a href="#">系统设置</a></li>
				<li class="divider"></li>
				<li>
					<a href="${pageContext.request.contextPath }/logout.action">
					退出登录
					</a>
				</li>
			</ul> 
		</li>
		<!-- 用户信息和系统设置结束 -->
	</ul>
	<!-- 左侧显示列表部分 start-->
	<div class="navbar-default sidebar" role="navigation">
		<div class="sidebar-nav navbar-collapse">
			<ul class="nav" id="side-menu">
				<li class="sidebar-search">
					<div class="input-group custom-search-form">
						<input type="text" class="form-control" placeholder="查询内容...">
						<span class="input-group-btn">
							<button class="btn btn-default" type="button">
								查询
							</button>
						</span>
					</div> 
				</li>
				<li>
				    <a href="${pageContext.request.contextPath }/customer/list.action" class="active">
				      客户管理
				    </a>
				</li>
				<li>
				    <a href="${pageContext.request.contextPath }/user/list.action" class="active">
				      用户管理
				    </a>
				</li>
				<li>
				    <a href="${pageContext.request.contextPath }/basedict/list.action" class="active">
				      数据字典管理
				    </a>
				</li>
				<li>
				    <a href="${pageContext.request.contextPath }/orders/list.action" class="active">
				      订单管理
				    </a>
				</li>
				<li>
				    <a href="${pageContext.request.contextPath }/product/list.action" class="active">
				      产品管理
				    </a>
				</li>
				<li>
				    <a href="${pageContext.request.contextPath }/project/list.action" class="active">
				      项目管理
				    </a>
				</li>
			</ul>
		</div>
	</div>
	<!-- 左侧显示列表部分 end--> 
  </nav>
  </nav>
  		<!--数据字典列表查询部分  start-->
		<div id="page-wrapper">
			<div class="row">
				<div class="col-lg-12">
					<h1 class="page-header">数据字典管理</h1>
				</div>
				<!-- /.col-lg-12 -->
			</div>
			<!-- /.row -->
			<div class="panel panel-default">
				<div class="panel-body">
					<form class="form-inline" method="get"
						action="${pageContext.request.contextPath }/basedict/list.action">
						<div class="form-group">
							<label for="dictTypeCode">类别代码</label> <input type="text"
								class="form-control" id="dictTypeCode" value="${dictTypeCode }"
								name="dictTypeCode" />
						</div>
						<div class="form-group">
							<label for="dictItemName">项目名称</label> <input type="text"
								class="form-control" id="dictItemName" value="${dictItemName }"
								name="dictItemName" />
						</div>
						<div class="form-group">
							<label for="dictTypeName">类别名称</label> <select
								class="form-control" id="dictTypeName" name="dictTypeName">
								<option value="">--请选择--</option>
								<c:forEach items="${dictTypeList}" var="item">
									<option value="${item.dict_type_name}"
										<c:if test="${item.dict_type_name == dictTypeName}">selected</c:if>>
										${item.dict_type_name }</option>
								</c:forEach>
							</select>
						</div>
						<button type="submit" class="btn btn-primary">查询</button>
					</form>
				</div>
			</div>
			<!-- 新建数据字典 -->
			<a href="#" class="btn btn-primary" data-toggle="modal"
				data-target="#newBaseDictDialog" onclick="clearBaseDict()">新建</a>
			<div class="row">
				<div class="col-lg-12">
					<div class="panel panel-default">
						<div class="panel-heading">数据字典信息列表</div>
						<!-- /.panel-heading -->
						<table class="table table-bordered table-striped">
							<thead>
								<tr>
								<th>数据字典id</th>
								<th>类别代码</th>
								<th>类别名称</th>
								<th>项目名称</th>
								<th>排序字段</th>
								<th>是否启用</th>
								<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${page.rows}" var="row">
									<tr>
									<td>${row.dict_id}</td>
									<td>${row.dict_type_code}</td>
									<td>${row.dict_type_name}</td>
									<td>${row.dict_item_name}</td>
									<td>${row.dict_sort}</td>
									<td>${row.dict_enable}</td>
										<td><a href="#" class="btn btn-primary btn-xs"
											data-toggle="modal" data-target="#baseDictEditDialog"
											onclick="editBaseDict(${row.dict_id})">修改</a> 
									    </td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
						<div class="col-md-12 text-right">
							<ujn:page
								url="${pageContext.request.contextPath }/basedict/list.action" />
						</div>
						<!-- /.panel-body -->
					</div>
					<!-- /.panel -->
				</div>
				<!-- /.col-lg-12 -->
			</div>
		</div>
		<!-- 数据字典列表查询部分  end-->
	</div>
	<!-- 创建数据字典模态框 -->
	<div class="modal fade" id="newBaseDictDialog" tabindex="-1"
		role="dialog" aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="myModalLabel">新建数据字典信息</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal" id="new_base_dict_form">
						<div class="form-group">
							<label for="new_baseDictTypeCode" class="col-sm-2 control-label">
								 类别代码 </label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="new_baseDictTypeCode"
									placeholder="类别代码" name="dictTypeCode" />
							</div>
						</div>
						<div class="form-group">
							<label for="new_baseDictTypeName"
								style="float: left; padding: 7px 15px 0 27px;">字典分类</label>
							<div class="col-sm-10">
								<select class="form-control" id="new_baseDictTypeName"
									name="dictTypeName">
								<option value="">--请选择--</option>
								<c:forEach items="${dictTypeList}" var="item">
									<option value="${item.dict_type_name}"
										<c:if test="${item.dict_type_name == dict_type_name}">selected</c:if>>
										${item.dict_type_name }</option>
								</c:forEach>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label for="new_baseDictName" class="col-sm-2 control-label">
								 项目名称 </label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="new_baseDictName"
									placeholder="项目名称" name="dictItemName" />
							</div>
						</div>
						<div class="form-group">
							<label for="new_dictEnable"
								style="float: left; padding: 7px 15px 0 27px;">是否启用</label>
							<div class="col-sm-10">
								<select class="form-control" id="new_dictEnable"
									name="dictEnable">
								<option value="">--请选择--</option>
								<option value="1">是</option>
								<option value="0">否</option>
								</select>
							</div>
						</div>
					</form>
			    </div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary"
						onclick="createBaseDict()">创建数据字典</button>
				</div>
			</div>
		</div>
	</div>
	<!-- 修改数据字典模态框 -->
	<div class="modal fade" id="baseDictEditDialog" tabindex="-1"
		role="dialog" aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="myModalLabel">修改字典项信息</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal" id="edit_base_dict_form">
						<input type="hidden" id="edit_dictId" name="dict_id" />
					<input type="hidden" id="edit_dictSort" name="dict_sort"/>
						<div class="form-group">
							<label for="edit_dictTypeCode" 
								style="float: left; padding: 7px 15px 0 27px;">类别代码</label>
							<div class="col-sm-10">
							<input type="text" class="form-control" id="edit_dictTypeCode" name="dict_type_code" />
							</div>
						</div>
						<div class="form-group">
							<label for="edit_dictTypeName" 
								style="float: left; padding: 7px 15px 0 27px;">类别名称</label>
							<div class="col-sm-10">
							<input type="text" class="form-control" id="edit_dictTypeName" name="dict_type_name" />
							</div>
						</div>
						<div class="form-group">
							<label for="edit_dictItemName" class="col-sm-2 control-label">项目名称</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="edit_dictItemName"
									placeholder="项目名称" name="dict_item_name" />
							</div>
						</div>
						<div class="form-group">
						<label for="edit_dictEnable" style="float:left;padding:7px 15px 0 27px;">是否启动</label>
						<div class="col-sm-10"> 
							<select	class="form-control" id="edit_dictEnable" name="dict_enable">
								<option value="">--请选择--</option>
								<c:forEach items="${isEnable}" var="item">
									<option value="${item.key}"<c:if test="${item.value == dictEnable}"> selected</c:if>>${item.value}</option>
								</c:forEach>
							</select>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary"
						onclick="updateBaseDict()">保存</button>
				</div>
			</div>
		</div>
	</div>
	
	<!-- 引入js文件 -->
	<!-- jQuery -->
	<script src="<%=basePath%>js/jquery-1.11.3.min.js"></script>
	<!-- Bootstrap Core JavaScript -->
	<script src="<%=basePath%>js/bootstrap.min.js"></script>
	<!-- Metis Menu Plugin JavaScript -->
	<script src="<%=basePath%>js/metisMenu.min.js"></script>
	<!-- DataTables JavaScript -->
	<script src="<%=basePath%>js/jquery.dataTables.min.js"></script>
	<script src="<%=basePath%>js/dataTables.bootstrap.min.js"></script>
	<!-- Custom Theme JavaScript -->
	<script src="<%=basePath%>js/sb-admin-2.js"></script>
	<!-- 编写js代码 -->
	<script type="text/javascript">
	//清空新建数据字典中的数据
	function clearBaseDict() {
	    $("#new_baseDictName").val("");
	    $("#new_baseDictTypeName").val("")
	    $("#new_dictEnable").val("")
	    $("#new_baseDictTypeCode").val("")
	}
	// 创建数据字典项
	function createBaseDict() {
	$.post("<%=basePath%>basedict/create.action",
	$("#new_base_dict_form").serialize(), function(data){
	        if(data =="OK"){
	            alert("字典项创建成功！");
	            window.location.reload();
	        }else{
	            alert("字典项创建失败！");
	            window.location.reload();
	        }
	    });
	}
	// 通过id获取修改的数据字典信息
	function editBaseDict(id) {
	    $.ajax({
	        type:"get",
	        url:"<%=basePath%>basedict/getBaseDictById.action",
	        data:{"id":id},
	        success:function(data) {
	            $("#edit_dictId").val(data.dict_id);
	            $("#edit_dictTypeCode").val(data.dict_type_code);
	            $("#edit_dictTypeName").val(data.dict_type_name);
	            $("#edit_dictItemName").val(data.dict_item_name);
	            $("#edit_dictSort").val(data.dict_sort);
	            $("#edit_dictEnable").val(data.dict_enable);
	        }
	    });
	}
    // 执行修改数据字典项操作
	function updateBaseDict() {
		$.post("<%=basePath%>basedict/update.action", $("#edit_base_dict_form").serialize(), function(data) {
			if(data =="OK") {
				alert("信息更新成功！");
				window.location.reload();
			} else {
				alert("信息更新失败！");
				window.location.reload();
			}
		});
	}

</script>
</body>
</html>
  